import {makeAutoObservable, runInAction} from "mobx";
import {IPageResponse} from "@/common/common";
import {apiQueryEvents, IEventReq} from "@/common/apis/event";

type TViewType = "list" | "card";
type TThumbnail = "thumb" | "nail";

class EventsStore {
  constructor() {
    makeAutoObservable(this)
  }

  loading = false
  viewType: TViewType = "card"
  thumbnailprop: TThumbnail = "thumb"
  isTotalSelected = false
  IsSelectAll = false
  selectedRowKeys = []
  markedResultIds = []
  queryParam: IEventReq = {}
  pageResponse: IPageResponse<any> = {
    data: [],
    pageInfo: {page: 1, size: 12, total: 0}
  }

  async queryEvents() {
    this.loading = true;
    const res = await apiQueryEvents(this.queryParam)
    return runInAction(() => {
      if (res.code === 0) {
        this.pageResponse = res
      }
      this.loading = false;
      return res;
    });
  }

  toggleIsTotalSelect() {
    this.isTotalSelected = !this.isTotalSelected;
  }

  toggleSelectAll() {

  }
}

export default new EventsStore()
